public class DomainGenerator
{
    public static IEnumerable<string> GenerateDomainLayer(string solutionPath, string sourceProjectPath, string targetProjectPath)
    {
        //On crer une liste qui contiendra le chemin de chaque fichier cre
        var filesToAddToProject = new List<string>();
        //On charge la solution
        ISolution solution = Solution.Load(solutionPath);
        //On rcupere nos deux projets (source et cible)
        var sourceProject = solution.Projects.First(p => p.Name == sourceProjectPath);
        var targetProject = solution.Projects.First(p => p.Name == targetProjectPath);
 
        //On rcupere tous les fichiers "Regular" (.cs ou .vb) du projet source
        var sourceDocuments = sourceProject.Documents.Where(d => d.SourceCodeKind == Roslyn.Compilers.SourceCodeKind.Regular);
 
        //Pour chaque fichier du projet source
        foreach (var document in sourceDocuments)
        {
            //On rcupere le type de compilation du projet
            CommonCompilation compilation = sourceProject.GetCompilation();
            //A partir du type de compilation on rcupere le model smantique du code source
            ISemanticModel model = compilation.GetSemanticModel(document.GetSyntaxTree());
            //On passe le model smantique au rewriter ddi au fichier source courant
            DomainRewriter rewriter = new DomainRewriter(model);
 
            //On lance l'analyse syntaxique de notre fichier source
            var finalCode = rewriter.Visit(document.GetSyntaxRoot() as CompilationUnitSyntax);
            //On rcupere le path du projet cible
            string targetDirectoryPath = Path.GetDirectoryName(targetProject.FilePath);
            string targetPath = Path.Combine(targetDirectoryPath, document.Name);
 
            //On crit dans le projet cible le fichier gnr.
            File.WriteAllText(targetPath, finalCode.NormalizeWhitespace().ToFullString());
 
            //On ajoute dans notre liste le chemin du fichier gnr
            filesToAddToProject.Add(targetPath);
        }
 
        return filesToAddToProject;
    }
}
